import React, {useContext, useEffect, useState} from 'react';
import './App.css';
import Home from "./pages/Home";
import Login from "./pages/login";

function App() {
    const isLogin = window.sessionStorage.getItem('isLogin')
    const userInfo = window.sessionStorage.getItem('userInfo')
    const [flag, setFlag] = useState(false)

    const setLoginInfo = (item: any, isLogin: string) => {
        window.sessionStorage.setItem('isLogin', isLogin)
        window.sessionStorage.setItem('userInfo', JSON.stringify(item))
        setFlag(value => !value)
    }

    if (isLogin === "true") {
        return <div className={'bgColor'}><Home setLoginInfo={setLoginInfo}/></div>
    } else {
        return <div className={'bgColor'}><Login setLoginInfo={setLoginInfo}/></div>
    }

}


export default App

